package com.hrc.springbootdemo.mq.rabbitmq.service;

import com.hrc.springbootdemo.mq.rabbitmq.config.RabbitConfig;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MessageSender {

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sendMessage(String message) {
        log.info("Sending message...");
        rabbitTemplate.convertAndSend(RabbitConfig.EXCHANGE_NAME, RabbitConfig.ROUTING_KEY, message);
    }
}